Skip to content

Line2: increase test coverage - #807

Merged
scpeters merged 4 commits into
mainfrom
scpeters/line2_more_test_coverage
Aug 24, 2026
Merged

Line2: increase test coverage#807
scpeters merged 4 commits into
mainfrom
scpeters/line2_more_test_coverage

Conversation

@scpeters

@scpeters scpeters commented Aug 21, 2026

Copy link
Copy Markdown
Member

🦟 Bug fix

Improve test coverage of Line2 class

Summary

This increases test coverage based on suggestions from Gemini. After observing some windows C4244 compiler warnings, I fixed them in 2a719e4:

  • Fix warnings in Set(double, double, double, double) by wrapping with static_cast<T>
  • Fix warning in Length() by using the simpler implementation from Line3.hh wrapped with static_cast<T>:

public: T Length() const
{
return this->pts[0].Distance(this->pts[1]);
}

Summary of test coverage improvements

  1. Set with Vector2 parameters: Verified setting start/end points using Vector2 instances.
  2. CrossProduct: Added explicit tests for both Line2 and Vector2 cross products. Expect CrossProduct of parallel lines is 0.
  3. OnSegment and Within: Tested points on segment, collinear points outside bounds, non-collinear points within bounding box, and endpoints.
  4. Intersect Branch Coverage:
    • Parallel collinear non-overlapping line segments.
    • Collinear lines where only the second endpoint lies on the segment.
    • Line extensions that intersect outside X or Y bounding ranges.
    • Intersect overload taking no output point.
  5. Operators: Expanded operator== and operator!= self-comparison checks.
  6. Template Types: Added test cases for Line2i (int) and Line2f (float).

Backport Policy

  • This is safe to backport to the following versions:
    • Jetty
    • Ionic
    • Harmonic
    • Fortress
  • This should not be backported
  • I am not sure
  • Other (fill in yourself)

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the fix (as needed)
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Assisted-by" to your commits. (See this policy for more info.)

Assisted-by: Gemini 3.6 Flash

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Backports: If this is a backport, please use Rebase and Merge instead.

1. Set with Vector2 parameters: Verified setting start/end points
   using Vector2 instances.
2. CrossProduct: Added explicit tests for both Line2 and Vector2
   cross products. Expect CrossProduct of parallel lines is 0.
3. OnSegment and Within: Tested points on segment, collinear points
   outside bounds, non-collinear points within bounding box, and endpoints.
4. Intersect Branch Coverage:
    • Parallel collinear non-overlapping line segments.
    • Collinear lines where only the second endpoint lies on the segment.
    • Line extensions that intersect outside X or Y bounding ranges.
    • Intersect overload taking no output point.
5. Operators: Expanded operator== and operator!= self-comparison checks.
6. Template Types: Added test cases for Line2i (int) and Line2f (float).

Assisted-by: Gemini 3.6 Flash

Signed-off-by: Steve Peters <scpeters@intrinsic.ai>
Signed-off-by: Steve Peters <scpeters@intrinsic.ai>
* Set: use static_cast<T>
* Length: use simpler approach from Line3::Length
  along with static_cast<T>

Signed-off-by: Steve Peters <scpeters@intrinsic.ai>
@scpeters
scpeters force-pushed the scpeters/line2_more_test_coverage branch from 84266d7 to 2a719e4 Compare August 21, 2026 01:55
@scpeters
scpeters marked this pull request as ready for review August 21, 2026 03:08
@scpeters scpeters changed the title Increase test coverage of Line2 class Line2: increase test coverage Aug 21, 2026
@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development Aug 24, 2026
@scpeters
scpeters enabled auto-merge (squash) August 24, 2026 21:40
@scpeters
scpeters merged commit 268039c into main Aug 24, 2026
14 checks passed
@scpeters
scpeters deleted the scpeters/line2_more_test_coverage branch August 24, 2026 21:44
@github-project-automation github-project-automation Bot moved this from In review to Done in Core development Aug 24, 2026
@ahcorde

ahcorde commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

https://github.com/Mergifyio backport gz-math9 gz-math8 gz-math7 ign-math6

@mergify

mergify Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

backport gz-math9 gz-math8 gz-math7 ign-math6

✅ Backports have been created

Details

Cherry-pick of 268039c has failed:

On branch mergify/bp/gz-math8/pr-807
Your branch is up to date with 'origin/gz-math8'.

You are currently cherry-picking commit 268039c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   include/gz/math/Line2.hh
	modified:   src/Line2_TEST.cc

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/python_pybind11/test/Line2_TEST.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Cherry-pick of 268039c has failed:

On branch mergify/bp/gz-math7/pr-807
Your branch is up to date with 'origin/gz-math7'.

You are currently cherry-picking commit 268039c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   include/gz/math/Line2.hh
	modified:   src/Line2_TEST.cc

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/python_pybind11/test/Line2_TEST.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Cherry-pick of 268039c has failed:

On branch mergify/bp/ign-math6/pr-807
Your branch is up to date with 'origin/ign-math6'.

You are currently cherry-picking commit 268039c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   src/Line2_TEST.cc

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   include/gz/math/Line2.hh
	both modified:   src/python_pybind11/test/Line2_TEST.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

ahcorde pushed a commit that referenced this pull request Aug 25, 2026
1. Set with Vector2 parameters: Verified setting start/end points
   using Vector2 instances.
2. CrossProduct: Added explicit tests for both Line2 and Vector2
   cross products. Expect CrossProduct of parallel lines is 0.
3. OnSegment and Within: Tested points on segment, collinear points
   outside bounds, non-collinear points within bounding box, and endpoints.
4. Intersect Branch Coverage:
    • Parallel collinear non-overlapping line segments.
    • Collinear lines where only the second endpoint lies on the segment.
    • Line extensions that intersect outside X or Y bounding ranges.
    • Intersect overload taking no output point.
5. Operators: Expanded operator== and operator!= self-comparison checks.
6. Template Types: Added test cases for Line2i (int) and Line2f (float).

Assisted-by: Gemini 3.6 Flash

Fix type conversion warnings
* Set: use static_cast<T>
* Length: use simpler approach from Line3::Length
  along with static_cast<T>


(cherry picked from commit 268039c)

Signed-off-by: Steve Peters <scpeters@intrinsic.ai>
Co-authored-by: Steve Peters <scpeters@intrinsic.ai>
ahcorde added a commit that referenced this pull request Aug 25, 2026
(cherry picked from commit 268039c)

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
Co-authored-by: Steve Peters <scpeters@intrinsic.ai>
Co-authored-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
ahcorde added a commit that referenced this pull request Aug 25, 2026
(cherry picked from commit 268039c)

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
Co-authored-by: Steve Peters <scpeters@intrinsic.ai>
Co-authored-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
caguero added a commit that referenced this pull request Aug 25, 2026
Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Carlos Agüero <caguero@honurobotics.com>
caguero added a commit that referenced this pull request Aug 25, 2026
Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Carlos Agüero <caguero@honurobotics.com>
caguero added a commit that referenced this pull request Aug 25, 2026
Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Carlos Agüero <caguero@honurobotics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants